package com.example.demo.repository;

import com.example.demo.entity.Product.WorkArea;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface WorkAreaCNRepository extends JpaRepository<WorkArea, Integer> {
    @Query("select w from WorkArea w where w.workingAreaCode = :workingAreaCode")
    WorkArea getAreaName(String workingAreaCode);

    @Query("select w from WorkArea w where w.property = :property")
    List<WorkArea> getAllWorkArea(String property);

    @Query(value = "select w.working_area_code,w.working_area_name,w.property from b_working_area w join b_user_working_area a on a.working_area_code = w.working_area_code where w.property like :property and a.user_code = :userID", nativeQuery = true)
    List<WorkArea> getUserWorkArea(@Param("property") String property, @Param("userID") String userId);
}